<!--
功能：公告组件,
作者：RanSheng,
邮箱：1534677527@qq.com",
时间：2021/5/31 17:27,
版本：v1.0,
修改记录：,
修改内容：,
修改人员：,
修改时间：,
-->
<template>
  <div>
    <div class="box-header">
      <el-carousel :interval="5000" arrow="hover">
        <el-carousel-item v-for="item in images" :key="item.id">
          <el-image :src="item.url"
                    class="image"
                    lazy
                    fit="fill"
                    @click="handle(item)">
          </el-image>
        </el-carousel-item>
      </el-carousel>
    </div>
    <div class="box-main">
      <div class="latest">
        <div class="latest-title">最新公告</div>
        <div class="latest-content">
          <div class="mon" v-if="dis">
            <span><i class="el-icon-loading"></i>暂无公告内容</span>
          </div>
          <div v-for="d in noticeList"
               class="content"
               :key="d.id">
            <div class="content-header">
              {{ d.title }}
            </div>
            <div class="content-main">
              {{ d.content }}
            </div>
            <div class="content-footer">
              <span>{{ d.user.name }}</span>
              <span>{{ d.time }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {message} from "@/utils/age";

export default {
  name: "Check",
  data() {
    return {
      dis: true,
      images: [{
        id: 1,
        url: require("../../assets/imag/g1.png")
      }, {
        id: 2,
        url: require("../../assets/imag/g2.png")
      }, {
        id: 3,
        url: require("../../assets/imag/g3.jpg")
      }],
      noticeList: []
    };
  },
  components: {},
  computed: {},
  mounted() {
    this.findAllNotice()
  },
  methods: {
    handle(item) {
      console.log(item)
    },
    findAllNotice() {
      this.$http.get('user/notice').then(response => {
        this.noticeList = response.data
        if (this.noticeList.length == 0) {
          this.dis = true
        } else {
          this.dis = false
        }
        message("success", "成功")
      }).catch(err => {
        message("error", "请求参数错误")
      })
    }
  },
  watch: {},
  destroyed() {

  },
}
</script>

<style scoped>
.mon {
  width: 100%;
  height: 200px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
  letter-spacing: 3px;
  color: #909399;
}

.mon i {
  margin-right: 8px;
}

/*详情信息 */
.content-header {
  height: 15%;
  background-color: #909399;
  border-radius: 8px 8px 0 0;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #ffffff;
  font-weight: 700;
}

.content-main {
  box-sizing: border-box;
  padding: 15px;
  height: 75%;
  letter-spacing: 2px;
  text-indent: 2em;
  line-height: 25px;
}

.content-footer {
  height: 10%;
  background-color: #6E6E6E;
  border-radius: 0 0 8px 8px;
  display: flex;
  justify-content: space-between;
  box-sizing: border-box;
  padding: 0 10px;
  color: #ffffff;
}


/**/
/*主题内容区域*/
.box-main {
  width: 100%;
  min-height: 400px;
  background-color: #F3F3F3;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.latest {
  margin-top: 20px;
  width: 93%;
}

.latest-title {
  font-size: 20px;
  border-left: 5px solid red;
  padding-left: 10px;
  box-sizing: border-box;
}

.latest-content {
  width: 100%;
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-content: space-between;
}

.content {
  width: 430px;
  height: 200px;
  margin: 22px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .3s;
  box-shadow: 0 0 6px 1px rgba(0, 0, 0, 0.1);
}

.content:hover {
  box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0.2);
}

/**/


/*头部样式*/
.box-header /deep/ .el-carousel__container {
  height: 400px;
}

.image {
  width: 100%;
  height: 400px;
  cursor: pointer;
}


/**/
</style>
